#ifndef _ASSETSWIDGET_H_
#define _ASSETSWIDGET_H_
#include <SEUi/Widget/Widget.h>
#include <SEngine/Project/Project.h>
#include <SEAssets/AssetsElem.h>
#include <SEUi/Dialog/Dialog.h>

namespace SEngine
{

    class Texture;
    struct TextureCache 
    {
        std::unique_ptr<Texture> tex;
        std::string path;
    };
    class EditLayer;
    class AssetsWidget : public Widget
    {
    public:
        AssetsWidget(EditLayer &);
        virtual ~AssetsWidget() = default;

    protected:
        virtual void BeginUpdate() override;
        virtual void UpdateImpl(int delta) override;
        virtual void EndUpdate() override;

    private:
        void DisplayFileTree(const std::string & name, AssetsElem & root);
        void DisplayFileTree_(AssetsElem & curPath);
        void ResetTree(std::optional<std::vector<std::string>> importedFiles);
        void ImportAssets();

        void OnImportHere(AssetsElem & node);
        void OnCreateMaterial(AssetsElem & node, const std::string & name, const std::string & temp);
        void OnCreateScript(AssetsElem & node, const std::string & name);
        void OnCreateShader(AssetsElem & node, const std::string & name);
        void OnDeleteAssets(AssetsElem & node);
        void OnShowInExplorer(AssetsElem & node);

        void OnScanFile();

    private:
        EditLayer & m_layer;
        ProjectOption m_opt;
        char m_tempNameBuffer[256] = {0};

        float m_loadProgressTotal{0.0f};
        float m_loadProgress{0.0f};
        std::string m_loadFileName;
        // bool m_showProgressBar{false};

        MessageDialog m_scanFileDialog;
    };
} // namespace SEngine


#endif